home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Copyright (C) 1997-1998 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //------------------------
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: July 15 1997
- // Author: cdg
- //
-
-
- global proc findBrowserWin() {
- //
- // Description:
- // Find a browser window of the correct type.
- //
- //
-
- global string $gHelpBrowserWinID = "";
- global int $gUseHelpBrowserWin = false;
-
- string $cmdStr;
- string $resStr;
- string $resStrs[];
- int $nArr;
- int $notDone = true;
- int $i;
-
- //
- // Generate a list of browser windows.
- //
- waitCursor -state on;
-
- $cmdStr = "xwininfo -root -tree | grep 'Netscape:'";
- $resStr = system($cmdStr);
- tokenize $resStr "\n" $resStrs;
-
- if (1 == size($resStrs) && "" == $resStrs[0]) {
- //
- // Netscape window isn't up yet. Check again.
- //
- for ($i = 0; $i < 5; $i++) {
- $resStr = system($cmdStr);
- tokenize $resStr "\n" $resStrs;
-
- if ("" != $resStrs[0]) {
- $gUseHelpBrowserWin = true;
- break;
- }
- }
- } else {
- $gUseHelpBrowserWin = true;
- }
-
- //
- // Test the windows to make sure that we have a browser window,
- // not a news, or mail window.
- //
- // If we are looking for an existing window start at the beginning
- // of the list. If we are looking for a new window start at the
- // end of the list.
- //
- $nArr = size ($resStrs);
- $i = $gUseHelpBrowserWin ? 0 : $nArr - 1;
- while ($notDone) {
- if ($i >= 0 && $i < $nArr) {
- //
- // Extract X window id
- //
- if ($gUseHelpBrowserWin) {
- $gHelpBrowserWinID = match("0x[0-9a-f]*", $resStrs[$i++]);
- } else {
- $gHelpBrowserWinID = match("0x[0-9a-f]*", $resStrs[$i--]);
- }
-
- if ($gHelpBrowserWinID != "") {
- //
- // Test for a browser window.
- //
- $resStr = system(("xprop -id "+ $gHelpBrowserWinID +
- " | grep WM_CLASS | grep Navigator"));
-
- if ("" != $resStr) {
- $notDone = false;
- }
- }
- } else {
- $notDone = false;
- }
- }
-
- waitCursor -state off;
- }
-
- global proc doBrowserHelp(string $args[]) {
- //
- // Description:
- // Launches a web browser for viewing help. The args array
- // provides a way of giving a hierarchical specification of
- // the help required. If no args are provided the top of the
- // help tree will be used.
- //
- // Arguments:
- // args[0] - Top Level eg. Commands, Tutorial, Animation, etc
- // args[1] - First sub heading eg. "ambientLight" for cmds
- // args[...] - as many more levels as needed to specify help required.
- //
- // Currently Defined Top Level args:
- // "Top" - Top of the help hierarchy. This is the default if no args
- // are supplied.
- // "Commands" - Documentation on individual commands.
- // "UserRelative" - The following args are a path relative to the help root
- // provided by the user. The will be appended to the root URL.
- // "UserAbsolute" - The following args provide a complete URL. They will not
- // be appended to the root URL.
- //
- //
-
- global string $gHelpBrowserWinID;
- global int $gUseHelpBrowserWin;
- global int $gRaiseHelpBrowserWin;
-
- int $i;
- int $nArgs = size($args);
- string $cmdStr;
- string $browserCmd = "netscape ";
- string $resStr;
- string $resStrs[];
- string $URL;
- string $helpRoot = getenv("MAYA_HELP_URL");
-
- int $len = `size($helpRoot)`;
- if (0 == $len) {
- // The environment variable wasn't set so try again
- $helpRoot = getenv("MAYA_LOCATION");
- $helpRoot += "/docs/en_US/html/";
- } else {
- // Make sure the string ends in a slash
- if (`substring $helpRoot $len $len` != "/") {
- $helpRoot += "/";
- }
- }
-
- //
- // Build appropriate URL
- //
- if ($nArgs == 0) {
- $URL = $helpRoot;
- } else if ("Top" == $args[0]) {
- $URL = ($helpRoot + "MasterIndex.html");
- } else if ("Commands" == $args[0]) {
- if ($nArgs == 1 ) {
- $URL = ($helpRoot + "Commands/index.html");
- } else {
- $URL = ($helpRoot + "Commands/" + $args[1]);
- }
- } else if ("UserRelative" == $args[0]) {
- if ($nArgs == 1 ) {
- //
- // No further info provided, just go to the root.
- //
- $URL = $helpRoot;
- } else {
- $URL = $helpRoot;
- for ($i = 1; $i < $nArgs; $i++) {
- $URL += $args[$i];
- if ($i < $nArgs-1) {
- $URL += "/";
- }
- }
- }
- } else if ("UserAbsolute" == $args[0]) {
- if ($nArgs == 1 ) {
- //
- // No further info provided, just go to the root.
- //
- $URL = $helpRoot;
- } else {
- $URL = "";
- for ($i = 1; $i < $nArgs; $i++) {
- $URL += $args[$i];
- if ($i < $nArgs-1) {
- $URL += "/";
- }
- }
- }
- } else {
- $URL = $helpRoot;
- }
-
-
- //NT we want to execute the URL and let windows
- //locate the default browser for us.
- if (`about -nt`) {
- string $upperURL = toupper($URL);
- if (!gmatch($upperURL, "HTTP:*")) {
- $URL = unconvert($URL); // Only convert if using the file system.
- }
-
- if( false && `optionVar -q helpInMainWindow` ) {
- htmlWidget -edit -url $URL helpPanel1HelpWidget;
- }
- else {
- $URL = "load " + $URL; // load is keyword for our custom popen to use ShellExecute
- waitCursor -state on;
- $browserCmd = system($URL); // NT only
- waitCursor -state off;
- }
- }
- else
- {
-
- //
- // Build netscape cmd string
- //
- if ("" != system("ps -u `whoami` | grep netscape")) { // GG: not executed on NT
- //
- // Running copy of browser found.
- //
- if ("" != $gHelpBrowserWinID) {
- //
- // Already have a X window id. Check that it is still valid.
- //
- $resStr = system(("xwininfo -id "+$gHelpBrowserWinID)); // GG: not executed on NT
- if ("" == $resStr) {
- //
- // X id is no good. Window has been closed.
- //
- $gHelpBrowserWinID = "";
- }
- }
-
- if ($gUseHelpBrowserWin && $gHelpBrowserWinID == "") {
- //
- // Find an existing browser window.
- //
- waitCursor -state on;
- findBrowserWin;
- waitCursor -state off;
- }
-
-
- if ("" != $gHelpBrowserWinID) {
- //
- // Specify which window we want to use.
- //
- $browserCmd += ("-id " + $gHelpBrowserWinID + " ");
- }
-
- //
- // Add 'raise' window option.
- //
- if ($gRaiseHelpBrowserWin && "" != $gHelpBrowserWinID) {
- $browserCmd += "-raise ";
- } else {
- $browserCmd += "-noraise ";
- }
-
- //
- // Specify the URL, and whether we want a new window.
- //
- $browserCmd += ("-remote 'openURL(" + $URL);
- if (!$gUseHelpBrowserWin && "" == $gHelpBrowserWinID) {
- $browserCmd += ",new-window)'";
- } else {
- $browserCmd += ")'&";
- }
-
- } else {
- //
- // Open a new version of the browser. Need to use a shell script
- // so that it won't block.
- //
- $gHelpBrowserWinID = "";
- $browserCmd = ("launchNetscapeHelp "+ $URL);
- }
-
- //
- // Run the shell cmd to start or communicate with the browser..
- //
- waitCursor -state on;
- system($browserCmd); // GG: not executed on NT
- waitCursor -state off;
-
- if ("" == $gHelpBrowserWinID) {
- //
- // Remember the window id for next time.
- //
- findBrowserWin;
- }
-
- }//NT end exist
-
- }
-